<%-- Page to display user registry form. --%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ page errorPage="WEB-INF/errorpage.jsp"%>

<%@ page import="com.kha.Trainee"%>

<!DOCTYPE html>
<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Trainee Registration</title>
<link rel="stylesheet" type="text/css" href="vendor/css/bootstrap.css">

</head>

<body>

	<div class="navbar navbar">
		<div class="navbar-inner">

			<div class="container">
				<a class="brand" href="#">Trainee Registration</a>
			</div>

		</div>
	</div>

	<div class="container">

		<%-- input validation message. --%>		

		<%
			Trainee trainee = (Trainee) session.getAttribute("trainee");
		
			if (trainee != null && trainee.isValid() != true){
				
				// Display message.
				if (request.getAttribute("account_message") != null){
					
					%> 
					
					<jsp:include page="/WEB-INF/view/alert.jsp">
						<jsp:param value='<%=request.getAttribute("account_message")%>' name="msg" />
						</jsp:include>
					
					<%
				}
				

				if (request.getAttribute("firstname_message") != null){
					%> 
					
					<jsp:include page="/WEB-INF/view/alert.jsp">
						<jsp:param value='<%=request.getAttribute("firstname_message")%>' name="msg" />
						</jsp:include>
					
					<%
				}
				

				if (request.getAttribute("lastname_message") != null){
					%> 
					
					<jsp:include page="/WEB-INF/view/alert.jsp">
						<jsp:param value='<%=request.getAttribute("lastname_message")%>' name="msg" />
						</jsp:include>
					
					<%
				}
				

				if (request.getAttribute("email_message") != null){
					%> 
					
					<jsp:include page="/WEB-INF/view/alert.jsp">
						<jsp:param value='<%=request.getAttribute("email_message")%>' name="msg" />
						</jsp:include>
					
					<%
				}
				
			}
		%>		

		<!-- Form to input data. -->

		<form class="form-horizontal" method="post" action="ValidateServlet">

			<div class="control-group">
				<label class="control-label" for="inputAccount">Account</label>
				<div class="controls">
					<input type="text" id="inputAccount" placeholder="your account"
						name="txtAccount"
						value=<%if (trainee != null) {
									out.print(trainee.getAccount());
								}%>>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label" for="inputFirstName">Firstname</label>
				<div class="controls">
					<input type="text" id="inputFirstName" placeholder="your firstname"
						name="txtFirstName"
						value=<%if (trainee != null) {
										out.print(trainee.getFirstname());
								}%>>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label" for="inputLastName">Lastname</label>
				<div class="controls">
					<input type="text" id="inputLastName" placeholder="your lastname"
						name="txtLastName"
						value=<%if (trainee != null) {
									out.print(trainee.getLastname());
								}%>>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label" for="inputEmail">Email</label>
				<div class="controls">
					<input type="text" id="inputEmail" placeholder="your email"
						name="txtEmail"
						value=<%if (trainee != null) {
									out.print(trainee.getEmail());
								}%>>
				</div>
			</div>

			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn">Submit</button>
				</div>
			</div>

		</form>
	</div>

</body>
</html>